package com.wkhyapp.lm.view;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.wkhyapp.lm.R;
import com.wkhyapp.lm.base.SuperActivity;
import com.wkhyapp.lm.contract.PhoneLoginPresenter;
import com.wkhyapp.lm.contract.PhoneLoginView;
import com.wkhyapp.lm.http.vo.Member;
import com.wkhyapp.lm.utils.MemberUtils;

import butterknife.BindView;

public class UpdatePwdActivity extends SuperActivity<PhoneLoginPresenter> implements PhoneLoginView {




    @BindView(R.id.pwd_et)
    EditText pwd_et;
    @BindView(R.id.login_rl)
    RelativeLayout login_rl;
    @BindView(R.id.back_iv)
    ImageView back_iv;
    String phone;
    @Override
    public void initUI() {
        phone = getIntent().getStringExtra("0");
    }

    @Override
    protected void initListener() {
        login_rl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if("".equals(pwd_et.getText().toString())){
                    TToast("请输入新密码");
                    return;
                }

                if(pwd_et.getText().toString().length()>12||pwd_et.getText().toString().length()<6){
                    TToast("请输入6位数新密码");
                    return;
                }

                showLoad("正在修改");
                mPresenter.updatePwd(phone,pwd_et.getText().toString().trim());
            }
        });

        back_iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void loginSucc(Member member) {
        TToast("修改成功");
        finish();
    }

    @Override
    public void loginFial(String str) {
        TToast(str);
    }

    @Override
    public void getCode(String str) {
        TToast("修改成功");
        finish();
    }

    @Override
    public void verSucc(String str) {

    }

    @Override
    protected PhoneLoginPresenter createPresenter() {
        return mPresenter = new PhoneLoginPresenter(this);
    }
    @Override
    protected void afterCreate() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_update_pwd;
    }



}
